<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
	<meta charset="utf-8" />
	<title>{$Think.lang.usr_edit_page_title} - {$Think.lang.cfg_website}</title>
	<meta content="width=device-width, initial-scale=1.0" name="viewport" />
	<meta content="" name="description" />
	<meta content="" name="author" />
	<!-- BEGIN GLOBAL MANDATORY STYLES -->
	<link href="{$NOW_THEME_URL}/Assets/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
	<link href="{$NOW_THEME_URL}/Assets/plugins/bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet" type="text/css"/>
	<link href="{$NOW_THEME_URL}/Assets/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css"/>
	<link href="{$NOW_THEME_URL}/Assets/css/style-metro.css" rel="stylesheet" type="text/css"/>
	<link href="{$NOW_THEME_URL}/Assets/css/style.css" rel="stylesheet" type="text/css"/>
	<link href="{$NOW_THEME_URL}/Assets/css/style-responsive.css" rel="stylesheet" type="text/css"/>
	<link href="{$NOW_THEME_URL}/Assets/css/themes/{:session('skin')}.css" rel="stylesheet" type="text/css" id="style_color"/>
	<!-- END GLOBAL MANDATORY STYLES -->
	<!-- BEGIN PAGE LEVEL STYLES -->
	<!-- END PAGE LEVEL STYLES -->
	<link rel="shortcut icon" href="favicon.ico" />
</head>
<!-- END HEAD -->
<!-- BEGIN BODY -->
<body class="page-header-fixed">
	<!-- BEGIN HEADER -->
	<include file="Public:header" />
	<!-- END HEADER -->
	<!-- BEGIN CONTAINER -->
	<div class="page-container">
		<!-- BEGIN SIDEBAR -->
		<div class="page-sidebar nav-collapse collapse">
			<!-- BEGIN SIDEBAR MENU -->        
			<ul class="page-sidebar-menu">
            	<li>
					<!-- BEGIN SIDEBAR TOGGLER BUTTON -->
					<div class="sidebar-toggler hidden-phone"></div>
					<!-- BEGIN SIDEBAR TOGGLER BUTTON -->
				</li>
                {$menu_tree}
            </ul>
			<!-- END SIDEBAR MENU -->
		</div>
		<!-- END SIDEBAR -->
		<!-- BEGIN PAGE -->
		<div class="page-content">
			<!-- BEGIN SAMPLE PORTLET CONFIGURATION MODAL FORM-->
			<div id="portlet-config" class="modal hide">
				<div class="modal-header">
					<button data-dismiss="modal" class="close" type="button"></button>
					<h3>portlet Settings</h3>
				</div>
				<div class="modal-body">
					<p>Here will be a configuration form</p>
			  </div>
			</div>
			<!-- END SAMPLE PORTLET CONFIGURATION MODAL FORM-->
			<!-- BEGIN PAGE CONTAINER-->
			<div class="container-fluid">
				<!-- BEGIN PAGE HEADER-->   
			  <div class="row-fluid">
					<div class="span12">
                    	<div class="clear">&nbsp;</div>                        
						<ul class="breadcrumb">
							<li>
								<i class="icon-home"></i>
								<a href="__APP__">{$Think.lang.cfg_page_home}</a> 
								<span class="icon-angle-right"></span>
							</li>
							<li>
								<a href="__URL__">{$Think.lang.usr_page_title}</a> 
								<span class="icon-angle-right"></span>
						  </li>
							<li><a href="#">{$Think.lang.usr_edit_page_title}</a></li>
						</ul>
					</div>
				</div>
				<!-- END PAGE HEADER-->
				<!-- BEGIN PAGE CONTENT-->
				<div class="row-fluid">
					<div class="span12">
						<!-- BEGIN VALIDATION STATES-->
						<div class="portlet box purple">
							<div class="portlet-title">
								<div class="caption"><i class="icon-reorder"></i>{$Think.lang.usr_edit_page_title}</div>
								<div class="tools">
									<a href="javascript:;" class="collapse"></a>
								</div>
							</div>
							<div class="portlet-body form">
								<!-- BEGIN FORM-->
								<form action="__URL__/edit" method="post" id="adcontentForm" class="form-horizontal">
                                	<input type="hidden" name="id" value="{$user['id']}">
                                    <input type="hidden" name="solevar" value="{$user['solevar']}">
									<div class="alert alert-error hide">
										<button class="close" data-dismiss="alert"></button>
										{$Think.lang.cfg_form_err_allform}
									</div>
									<div class="alert alert-success hide">
										<button class="close" data-dismiss="alert"></button>
										{$Think.lang.cfg_form_ok_allform}
									</div>
                                     <div class="tabbable tabbable-custom">
                                     
                                    <ul class="nav nav-tabs">
                                        <li class="active"><a href="#tab_1_1" data-toggle="tab">
                                        {$Think.lang.usr_form_ftitle_base}</a></li>
                                        <li><a href="#tab_1_2" data-toggle="tab">
                                        {$Think.lang.usr_form_ftitle_personal}</a></li>
                                    </ul>
                                  <div class="tab-content">
                                  <!--tab1 start-->
                                  <div class="tab-pane active" id="tab_1_1">
                               		
									<div class="control-group">
										<label class="control-label">{$Think.lang.usr_form_ele_username}</label>
										<div class="controls">
                                       		 <div class="input-icon left"><i class="icon-user"></i>
											 <input type="text" name="username" value="{$user['username']}" data-required="1" 
                                             class="span6 m-wrap" disabled readonly/>
                                             </div>
										</div>
									</div>
                                    
                                    <div class="control-group">
										<label class="control-label">{$Think.lang.usr_form_ele_password}
                                        <span class="required">*</span></label>
										<div class="controls">
                                        	<div class="input-icon left"><i class="icon-lock"></i>
											<input type="password" name="epassword" data-required="1" class="span6 m-wrap"
                                             value="{:C('CONFUSE')}"/>
                                            </div>
										</div>
									</div>
                                    
                                    <div class="control-group">
										<label class="control-label">{$Think.lang.usr_form_ele_password_re}
                                        <span class="required">*</span></label>
										<div class="controls">
                                        	<div class="input-icon left"><i class="icon-lock"></i>
											<input type="password" name="password_re" data-required="1" class="span6 m-wrap"
                                             value="{:C('CONFUSE')}"/>
                                            </div>
										</div>
									</div>
            
									<div class="control-group">
										<label class="control-label">{$Think.lang.usr_form_ele_role}
                                        <span class="required">*</span></label>
										<div class="controls">
											<select class="span6 m-wrap" name="role" id="role">
												<option value="">{$Think.lang.cfg_form_tis_select}</option>
                                                {$roles}
											</select>
										</div>
									</div>
									
									<div class="control-group" id="outlet" style="display:none">
										<label class="control-label">所属门店
                                        <span class="required">*</span></label>
                                        
                                        <div class="controls" style="margin-bottom:10px">
                                        	 选择地区<div id="areaBox"></div>
                                        </div>
                                       
										<div class="controls">
											选择门店<br>
											<select class="span6 m-wrap" name="outletid" id="outletid">
												<option value="">{$Think.lang.cfg_form_tis_select}</option>
                                                <volist name="outlet" id="v">
                                                <option value="{$v.outletid}"
                                                <eq name="v.outletid" value="$user.outletid">selected</eq>
                                                >{$v.title}</option>
                                                </volist>
											</select>
										</div>
									</div>
                                    
                                     <div class="control-group">
										<label class="control-label">{$Think.lang.usr_form_ele_email}
                                        <span class="required">*</span></label>									
										<div class="controls">
                                        	<div class="input-icon left"><i class="icon-envelope"></i>
											<input type="text" name="email" data-required="1" class="span6 m-wrap"  
                                             placeholder="{$Think.lang.usr_form_validata_email_tis}" value="{$user['email']}"/>									
                                             </div>
										</div>
									</div>
									
									 <div class="control-group">
										<label class="control-label">{$Think.lang.usr_form_ele_phone}</label>
										<div class="controls">
											<input type="text" name="phone" value="{$user['phone']}" data-required="1" 
                                             class="span6 m-wrap"/>
										</div>
									</div>
                                    
                                    <div class="control-group">
										<label class="control-label">{$Think.lang.usr_form_ele_status}
                                        <span class="required">*</span></label>
										<div class="controls">
											<label class="radio">
											<div class="radio"><span>
                                            <input type="radio" value="1" name="status" checked="checked"
                                            <eq name="user.status" value="1">checked</eq>>
                                            </span></div>{$Think.lang.usr_form_ele_status_1}
											</label>
											
                                            <label class="radio">
											<div class="radio"><span><input type="radio" value="2" name="status"
                                             <eq name="user.status" value="2">checked</eq>></span>
                                             </div>{$Think.lang.usr_form_ele_status_2}
											</label>
										</div>
									</div>
                                    
                                  </div>
                                  <!--tab1 end-->
                                  <!--tab2 start-->
                                  <div class="tab-pane" id="tab_1_2">
                                    
                                    <div class="control-group">
										<label class="control-label">{$Think.lang.usr_form_ele_pic}</label>
										<div class="controls">
											<a class="btn blue" id="uploadSinglePic" data-toggle="modal">
                                            <i class="icon-picture"></i> {$Think.lang.cfg_upl_thumbpic_btn}</a>
                                            <div class="clear"></div>
                                            <div id="singleBox" class="uploadPic_box">
                                              <notempty  name="single">
                                              <dl>
                                              <dt>
                                              	  <img src="{$Think.UPLOAD_URL}{$single.fileurl}">
                                              </dt>
                                              <dd class="picname">
                                                  <input type="text" name="single_title[]" value="{$single.c_title}">
                                                  <input type="hidden" name="single_url[]" 
                                                   value="{$Think.UPLOAD_URL}{$single.fileurl}">
                                              </dd>
                                              <dd class="pictool">
                                                  <span class="pdel">
                                                  <i class="icon-remove-sign"></i>
                                                  </span>
                                                  <span class="pzoom">
                                                  <i class="icon-cut"></i>
                                                  </span>
                                                  <span class="pshow">
                                                  <i class="icon-eye-open"></i>
                                                  </span>
                                              </dd>
                                              </dl>
                                              </notempty>
                                            </div>
										</div>
									</div>
                                    
                                    <div class="control-group">
										<label class="control-label">{$Think.lang.usr_form_ele_realname}</label>
										<div class="controls">
											<input type="text" name="realname" value="{$user['realname']}" data-required="1" 
                                            class="span6 m-wrap"/>
										</div>
									</div>
                                    <div class="control-group">
										<label class="control-label">{$Think.lang.usr_form_ele_sex}
                                        <span class="required">*</span></label>
										<div class="controls">
											<label class="radio">
											<div class="radio"><span><input type="radio" value="1" name="sex" 
                                            <php>
                                            	if($user['sex']==1)echo 'checked="checked"';
                                            </php>
                                            ></span></div>{$Think.lang.usr_form_ele_sex_1}
											</label>
                                            
                                            <label class="radio">
											<div class="radio"><span><input type="radio" value="2" name="sex"
                                            <php>
                                            	if($user['sex']==2)echo 'checked="checked"';
                                            </php>></span>
                                            </div>{$Think.lang.usr_form_ele_sex_2}
											</label>
										</div>
									</div>
                                   
                                   {$user['lang']|eleLangShow=###}
                                   
                                    
                                  <div class="control-group">
										<label class="control-label">{$Think.lang.usr_form_ele_skin}</label>
										<div class="controls">
											<select class="span6 m-wrap" name="skin">
												<option value="">{$Think.lang.cfg_form_tis_select}</option>
                                                <option value="default" <eq name="user.skin" value="default">
                                                 selected</eq>>Black</option>
                                                <option value="blue" <eq name="user.skin" value="black">
                                                 selected</eq>>Blue</option>
                                                <option value="brown" <eq name="user.skin" value="brown">
                                                 selected</eq>>Brown</option>
                                                <option value="purple" <eq name="user.skin" value="purple">
                                                 selected</eq>>Purple</option>
                                                <option value="light" <eq name="user.skin" value="light">
                                                 selected</eq>>Light</option>
											</select>
										</div>
									</div>                            
		
                                    <div class="control-group">
										<label class="control-label">{$Think.lang.usr_form_ele_remark}</label>
										<div class="controls">
                                          <textarea rows="3" name="remark" class="large m-wrap">{$user['remark']}</textarea>
										</div>
									</div>
                                    
                                  </div>
                                  <!--tab2 end-->     
                                </div>
                                </div>
                                    
									<div class="form-actions">
										<button type="submit" class="btn purple">{$Think.lang.cfg_form_ele_submit}</button>
										<button type="reset" class="btn">{$Think.lang.cfg_form_ele_reset}</button>
									</div>
								</form>
								<!-- END FORM-->
							</div>
						</div>
						<!-- END VALIDATION STATES-->
					</div>
				</div>
				<!-- END PAGE CONTENT-->         
		  </div>
			<!-- END PAGE CONTAINER-->
		</div>
		<!-- END PAGE -->
	</div>
	<!-- END CONTAINER -->
	<!-- BEGIN FOOTER -->
	<include file="Public:footer" />
	<!-- END FOOTER -->
	<!-- BEGIN JAVASCRIPTS(Load javascripts at bottom, this will reduce page load time) -->
	<!-- BEGIN CORE PLUGINS -->
	<script src="__PUBLIC__/Js/jquery.min.js" type="text/javascript"></script>
	<script src="{$NOW_THEME_URL}/Assets/plugins/jquery-migrate-1.2.1.min.js" type="text/javascript"></script>   
	<script src="{$NOW_THEME_URL}/Assets/plugins/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
	<!--[if lt IE 9]>
	<script src="{$NOW_THEME_URL}/Assets/plugins/excanvas.min.js"></script>
	<script src="{$NOW_THEME_URL}/Assets/plugins/respond.min.js"></script>  
	<![endif]-->  
	<script src="{$NOW_THEME_URL}/Assets/plugins/jquery.cookie.min.js" type="text/javascript"></script>
	<!-- END CORE PLUGINS -->
	<!-- BEGIN PAGE LEVEL PLUGINS -->
	<script type="text/javascript" src="{$NOW_THEME_URL}/Assets/plugins/jquery-validation/dist/jquery.validate.min.js"></script>
	<script type="text/javascript" src="{$NOW_THEME_URL}/Assets/plugins/jquery-validation/dist/additional-methods.min.js"></script>
    <script type="text/javascript" src="{$NOW_THEME_URL}/Assets/plugins/jquery-validation/localization/messages_zh.js"></script>
	<!-- END PAGE LEVEL PLUGINS -->
	<!-- BEGIN PAGE LEVEL STYLES -->
	<script src="{$NOW_THEME_URL}/Assets/scripts/app.js"></script>
	<script src="{$NOW_THEME_URL}/Assets/scripts/user/edit.js"></script> 
	<!-- END PAGE LEVEL STYLES -->    
     <!-- BEGIN UPLOADPIC-->
    <script type="text/javascript" src="{$NOW_THEME_URL}/Assets/plugins/artdialog/jquery.artdialog.js?skin=bootstrap"></script>
	<script type="text/javascript" src="{$NOW_THEME_URL}/Assets/plugins/artdialog/plugins/iframeTools.js"></script>
    <script src="{$NOW_THEME_URL}/Assets/scripts/upload/pic.js"></script>
    <!-- END UPLOADPIC-->
	<script type="text/javascript">
		var ABS_URL_Theme = "{$NOW_THEME_URL}/";
		
		//UploadPic STATES CONSTANT
		var ABS_URL = "{$Think.TMPL_URL}/";
		var REL_URL = "{$Think.REL_URL}";
		//UploadPic END CONSTANT
		
		var vMessage = {};//用户编辑表单的验证提示语言包
		vMessage.role_required        = '{$Think.lang.usr_form_validata_role_required}';
		vMessage.email_required       = '{$Think.lang.usr_form_validata_email_required}';
		vMessage.email_email          = '{$Think.lang.usr_form_validata_email_email}';
		vMessage.phone_regex          = '{$Think.lang.cfg_form_tipmsg_w_m}';
		
		var jsLang = {};
		jsLang.crop_title      = '{:L("cfg_upl_crop_title")}';
		jsLang.crop_false      = '{:L("cfg_upl_crop_false")}';
		jsLang.crop_noselect   = '{:L("cfg_upl_crop_noselect")}';
		jsLang.uploadSinglePic = '{:L("cfg_upl_thumbpic_btn")}';
		jsLang.uploadAtlasPic  = '{:L("cfg_upl_atlaspic_btn")}';
		
		jQuery(document).ready(function() {   
		   // initiate layout and plugins
		   App.init();
		   adcontentForm.init();
		   
		    uploadPic.init([
			 {
				'btn':'uploadSinglePic',
				'title':jsLang.uploadSinglePic,
				'box':'singleBox',
				'ptype':'single',
				'field':'single'
			  }
			],jsLang);
		    
		    $('#role').on("change",function(){
			   var outlet = $(this).find("option:selected").attr("outlet");
			   if(outlet == 1){
				   $('#outlet').show();
			   }else{
				   $('#outlet').hide();
			   }
		   });
		});
		
		function mapOutletArea(area){
			$.post("{:U('Public/mapOutlet')}",{'area':area,'type':'area'},function(data){
				dealOutlet(data);
			},"json");
		}
		
		function dealOutlet(data){
			var html  = "<option value=''>请选择门店</option>";
			var option= "";
			if(data.status == 1){
				var out = data.data;
				$.each(out,function(i){
					option += "<option value='"+out[i].outletid+"'>"+out[i].title+"</option>";
				});			
			}else{
				alert(data.info);
			}
			$('#outletid').html(html+option);
		}
		 
		//地址开始
		var linkage_json = {$json|json_encode} ;
		$(function(){
			
			$('#area4').live("change",function(){
				var area = $(this).val();
				mapOutletArea(area);
			});
			
			//初始值处理
			var did = '{$row.id}';
			if(did!=''){
				var level = "{$row.level}";
				$('#outlet').show();
				$('#areaBox').html(dealInitialarea(did,'',1));
			}else{
				$('#areaBox').html(showLinkagearea(39,2,0));
			}
			$('select[name="area"]').live('change',function(){
				var nowLevel = parseInt($(this).attr('level'));
				var nextLevel = nowLevel+1;
				//清除自此以后的select
				$('select[name="area"]').each(function(index, element) {
					if(parseInt($(this).attr('level'))>nowLevel){
						$(this).remove();
					}
				});
				$('#ssxadd').val($('select[name="area"]').find("option:selected").text());
				$('input[name="area'+nowLevel+'"]').val($(this).val());
				
				//显示下一个select
				$('#areaBox').append(showLinkagearea($(this).val(),nextLevel,0));
			});
			
			//处理初始值
			function dealInitialarea(lid,result,level){
				if(lid){
					$.each(linkage_json , function(i, n){
						if(lid==i){
							result = dealInitialarea(n[1],result,(parseInt(level)-1))+''+showLinkagearea(n[1],level,i);
							return false;
						}
					});
				}
				
				return result;
			}
			
			//响应select改变事件
			function showLinkagearea(pid,level,nid){
				var html = ''; //最终输出的HTML
				var have = false; //是否有子词典
				html += '<select name="area" id="area'+level+'" level="'+level+'" style="width:160px">';
				html += '<option value="0">请选择</option>';
				$.each(linkage_json , function(i, n){
					if(pid==n[1]){
						if(nid==i){
							html += '<option value="'+i+'" selected>'+n[0]+'</option>';
						}else{
							html += '<option value="'+i+'">'+n[0]+'</option>';
						}
						have = true;
					}
				});
				html += '</select>';
				html += '<input type="hidden" name="area'+level+'" />';
				
				//没有子词典则此次输出为空
				if(!have){
					html = '';
				}
				return html;
			}
		});
	</script>
	<!-- END JAVASCRIPTS -->   
</body>
<!-- END BODY -->
</html>